<%@page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%@ page import="java.util.*,java.io.*,java.text.*,org.apache.commons.lang.StringEscapeUtils" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<html>
<head>
	<script type="text/javascript">
		$(function() {
			
			loadSearchResult();
		});
		
		function loadSearchResult(){
			$.getJSON("<c:url value='/search.html' />", {
				q : "<c:out value='${param.q}' />"
			}, function(data) {
				if (data != null && data.ResultList!=null && data.ResultList.length>0) {
					for(var i=0; i<data.ResultList.length; i++){
						var searchItem = data.ResultList[i];
						
						var resultRow = document.createElement("div");
						$(resultRow).attr({class:"search_result_row"});
						
						var link = document.createElement("a");						
						$(link).attr({href:"#"});
						
						if(searchItem.category == "PRODUCT"){
							var param = new Array;
							param[0] = "productId="+searchItem.id;
							/* param[1] = "headerFileId="+product.fileId; */
							$(link).attr({
								href:'javascript:cfGoToPage(\"<c:url value="/page/product.html" />\",\"prod_detail\",\"'+param.join("&")+'\");'
								});
						}
						
						var desc = document.createElement("p");
						
						$(link).html("<h4>"+searchItem.title+"</h4>");
						$(desc).text(searchItem.description);
						
						$(link).appendTo(resultRow);
						$(desc).appendTo(resultRow);
						
						$(resultRow).appendTo($("#search_result_list"));
					}
				}else{
					var resultRow = document.createElement("div");
					$(resultRow).attr({class:"search_result_row"});
					
					var desc = document.createElement("p");
					$(desc).text("Result not found");
					$(desc).addClass("text_big");
					
					$(desc).appendTo(resultRow);
					$(resultRow).appendTo($("#search_result_list"));
				}
			});
		}
		
	</script>

</head>
<body>
	<img src="<c:url value='/html/image/icon/Note Pinned.png' />" alt="" title=""
		class="detail_section_icon" border="0">

	<h2 class="detail_title"><fmt:message key="vnnet.ket_qua_tim_kiem" /></h2>
	<div class="detail_subtitle"></div>
	<div class="clear"></div>
	
	<div class="detail_content_container">
		<%-- <div class="detail_content_header">
			<img class="thumbnail" alt="" src="<c:url value='/file/image.html?id=1' />" />
		</div> --%>
		<div class="detail_content_body" id="search_result_list">
			<!-- 
			<div class="search_result_row">
				<a href="#"><h4>Product 1</h4></a>
				<p>Testing description 1</p>
			</div> -->
		</div>
	</div>
	
	<div class="clear"></div>
</body>
</html>